$(function () {
    $('#btn').click(function () {
        const username = $('#uname').val()
        const pwd = $('#pwd').val()
        var url = 'http://127.0.0.1:3000/login/test'
        $.post(url, { username, pwd }, data => {
            console.log(data);
            if (data.code == 200) {
                /* console.log(data.data);
                const username=JSON.stringify(data.data[0].username)
                sessionStorage.setItem('username',username) */
                console.log(data);
                sessionStorage.setItem("username", data.data[0].username);
                console.log(data.data[0].username);
                alert('登录成功')
                window.location.href = 'index.html'
            }else{
                alert('帐号或密码错误')
            }
        })
    })
    $('#pwd').keyup(function (e) {
        //  回车编号是13
        if (e.keyCode == 13) {
            $('#btn').click()
        }
    })
})
